#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>
#include <QGridLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton *but1 = new QPushButton("按钮1");
    QPushButton *but2 = new QPushButton("按钮2");
    QPushButton *but3 = new QPushButton("按钮3");
    QPushButton *but4 = new QPushButton("按钮4");
    QPushButton *but5 = new QPushButton("按钮5");
    QPushButton *but6 = new QPushButton("按钮6");

    QGridLayout *out = new QGridLayout();
    out->addWidget(but1,0,0);
    out->addWidget(but2,0,1);
    out->addWidget(but3,0,2);
    out->addWidget(but4,1,0);
    out->addWidget(but5,1,1);
    out->addWidget(but6,1,2);
    this->setLayout(out);

    // 设置水平拉伸系数
    out->setColumnStretch(0,1);
    out->setColumnStretch(1,2);
    out->setColumnStretch(2,3);
}

Widget::~Widget()
{
    delete ui;
}
